{% extends 'base.html' %}
{% block content %}
<div class="container mt-4">
    <h2>工程安全监测新闻</h2>
    <div class="mb-3">
        <a href="{% url 'news-create' %}" class="btn btn-primary">添加新闻</a>
    </div>
    
    <div class="list-group">
        {% for news in news_list %}
        <div class="list-group-item">
            <div class="d-flex w-100 justify-content-between">
                <h5 class="mb-1">{{ news.title }}</h5>
                <small>{{ news.publish_date|date:'Y-m-d' }}</small>
            </div>
            <p class="mb-1">{{ news.content|truncatechars:100 }}</p>
            <small>分类: {{ news.get_category_display }}</small>
            <div class="mt-2">
                <a href="{% url 'news-update' news.pk %}" class="btn btn-sm btn-warning">编辑</a>
                <a href="{% url 'news-delete' news.pk %}" class="btn btn-sm btn-danger">删除</a>
            </div>
        </div>
        {% endfor %}
    </div>
</div>
{% endblock %}